import 'package:flutter/material.dart';

class MyTestPointer extends StatefulWidget {
  @override
  _MyTestPointerState createState() => _MyTestPointerState();
}

class _MyTestPointerState extends State<MyTestPointer> {
  @override
  Widget build(BuildContext context) {
    return Listener(
      onPointerDown: (events) {
        print("点击了哦");
      },
      child: SafeArea(
        child: Scaffold(
          body: Center(
            child: Container(
              color: Colors.green,
              child: Listener(
                behavior: HitTestBehavior.deferToChild,
                onPointerDown: (event) {
                  print('-------------');
                },
                child: ConstrainedBox(
                  constraints: BoxConstraints.tight(Size(300.0, 160.0)),
                  child: Center(
                    child: Listener(
                      onPointerDown: (event) {
                        print('点击我测试一下');
                      },
                      child: Text(
                        '点击我测试一下',
                        style: TextStyle(color: Colors.red),
                      ),
                    ),
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
